<%--
$Id: authority-list.jsp 13 2010-11-02 15:35:59Z feigme $
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/content/commons/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><fmt:message key="user.manager"/></title>
</head>
<body>
<%@ include file="user-menu.jsp" %>
<label id="error"><form:errors path="authority.*" cssStyle="color:red;"/></label>
<div>
<table width="100%">
	<tr>
		<td colspan="3">
		<form action="${ctx }/admin/authority/new" method="post">
		<fmt:message key="authority.new" />
			<input type="text" name="name"/>
			<input name="submit" type="submit" value="<fmt:message key="common.submit"/> "/>
		</form>
		</td>
	</tr>
</table>
<table width="50%" class="solidtable">	
	<tr>
		<td class="solidtr" width="30" align="center"><fmt:message key="common.id"/></td>
		<td class="solidtr" ><fmt:message key="authority.name"/></td>
		<td class="solidtr" align="center" width="130" ><fmt:message key="common.action"/></td>
	</tr>
	<c:forEach items="${authorities}" var="authority">
	<tr style="height:23px;">
		<td align="center"><c:out value="${authority.id}"/></td>
		<td><c:out value="${authority.name}"/></td>
		<td align="center">
			<a name="update" href="javascript:void(0);"><fmt:message key="common.update"/></a>
			| <a href="${ctx }/admin/authority/<c:out value="${authority.id}"/>/delete"><fmt:message key="common.delete"/></a>
		</td>
	</tr>
	<tr style="display: none;height:23px;">
		<td align="center"><c:out value="${authority.id}"/></td>
		<td>
			<form action="${ctx }/admin/authority/<c:out value="${authority.id}"/>/edit" method="post">
			<input type="text" name="name" value="<c:out value="${authority.name}"/>"/>
			<input name="submit" type="submit" value="<fmt:message key="common.submit"/> "/>
			</form>
		</td>
		<td align="center">
			<a name="cancel" href="javascript:void(0);"><fmt:message key="common.cancel"/></a>
		</td>
	</tr>
	</c:forEach>
</table>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$("a[name='update']").click(function(){
		$("a[name='cancel']").parent().parent().hide();
		$("a[name='update']").parent().parent().show();
		$(this).parent().parent().hide();
		$(this).parent().parent().next().show();
	});
	$("a[name='cancel']").click(function(){
		$("label").html("");
		$(this).parent().parent().hide();
		$(this).parent().parent().prev().show();
	});
	$("input[name='submit']").click(function(){
		if(jQuery.trim($(this).prev().val())==""){
			$("#error").html("<font color='red'> name is requied.</font>");
			return false;
		}
	});
});
</script>
</body>
</html>